# SPDX-FileCopyrightText: Copyright (C) swift Project Community / Contributors
# SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1

add_library(input SHARED
        joystick.cpp
        joystick.h
        keyboard.cpp
        keyboard.h
        swiftinputexport.h
)

if(WIN32)
    target_sources(input PRIVATE
        win/joystickwindows.cpp
        win/joystickwindows.h
        win/keyboardwindows.cpp
        win/keyboardwindows.h
    )
    target_compile_definitions(input PRIVATE DIRECTINPUT_VERSION=0x0800)
    target_link_libraries(input PUBLIC dxguid ole32 dinput8 User32)
elseif(APPLE)
    target_sources(input PRIVATE
        macos/joystickmacos.h
        macos/joystickmacos.mm
        macos/keyboardmacos.h
        macos/keyboardmacos.mm
        macos/macosinpututils.h
        macos/macosinpututils.mm
    )
    target_link_libraries(input PUBLIC "-framework CoreFoundation" "-framework ApplicationServices" "-framework Foundation" "-framework AppKit" "-framework IOKit")
else()
    target_sources(input PRIVATE
        linux/joysticklinux.cpp
        linux/joysticklinux.h
        linux/keyboardlinux.cpp
        linux/keyboardlinux.h
    )
endif()

target_include_directories(input PUBLIC ${PROJECT_SOURCE_DIR}/src)

target_link_libraries(input
        PUBLIC
            Qt::Core
            misc
)

target_compile_definitions(input PRIVATE BUILD_SWIFT_INPUT_LIB)

install(TARGETS input
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
)
